package com.sanhuo.security.dao;

import com.sanhuo.security.entity.UserToken;
import com.sanhuo.triild.Basic.BaseMapper;
import com.sanhuo.triild.annotation.Insert;
import com.sanhuo.triild.annotation.Mapper;
import com.sanhuo.triild.annotation.Select;
import com.sanhuo.triild.annotation.Update;

@Mapper
public interface UserTokenMapper extends BaseMapper<UserToken> {
    @Select("select * from user_token where userId = #{userId}")
    UserToken findByUserId(String userId);

    @Select("select * from user_token where tokenStr = #{tokenStr}")
    UserToken findByToken(String tokenStr);

    @Insert("INSERT INTO user_token values (#{id},#{userId},#{tokenStr},#{time})")
    void save(UserToken userToken);

    @Update("update user_token set tokenStr = #{tokenStr},time = #{time}" +
            " where userId = #{userId}")
    void update(UserToken userToken);
}
